<script setup lang="ts">
import { ref, onMounted } from 'vue';
// 标题组件
import LeftTitle from '../../components/LeftTitle.vue';
// 接口
import { getControlApi } from '../../api/index';
// 导入封装的echarts组件
import EchartsCom from '../../components/EchartsCom.vue';

// 定义类型
interface typeData {
    [key: string]: any
}

// 监控数据
const controlData: typeData = ref([]);

// echarts 数据
const option = ref({});

onMounted(async () => {
    const resp = await getControlApi();
    // console.log(resp.data.data.result[0], 11111);
    controlData.value = resp.data.data.result[0].tableData;
    option.value = resp.data.data.result[0].option;
});
</script>

<template>
    <div class="container">
        <LeftTitle title="门禁情况"></LeftTitle>
        <div class="control-box">
            <!-- 封装echart组件 -->
            <EchartsCom :option="option" :key="+new Date()"></EchartsCom>

            <div class="right-item">
                <div>
                    <p>男生</p>
                    <p>女生</p>
                </div>
                <div class="floor-box">
                    <div v-for="(item, index) in controlData" :key="index">
                        <p>{{ item.num }}</p>
                        <p>{{ item.floor }}</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<style scoped lang="scss">
.container {
    width: 100%;
    height: 28%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .control-box {
        flex: 1;
        margin-top: 2%;
        // width: 100%;
        // height: 72%;
        background-color: #092C75;
        display: flex;

        .right-item {
            width: calc(100% - 35%);
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-around;
            color: #D1DAE7;
            font-size: 13px;

            >div {
                width: 100%;
                height: 50%;
                display: flex;
                align-items: center;
                justify-content: space-evenly;

            }

            .floor-box {
                width: 100%;
                height: 100%;

                >div {
                    text-align: center;

                    >p:nth-child(2) {
                        display: block;
                        padding-bottom: 3px;
                        border-bottom: solid 2px #A3B6CF;
                    }
                }
            }
        }
    }
}
</style>